#include "go.h"
#include <assert.h>

Board::Board(int rows, int columns)
    : r(rows), c(columns)
{
    fld = new Field[r * c];
}

Board::~Board()
{
    delete []fld;
}

bool Board::validMove(int x, int y, Field color) const
{
    assert(x >= 0);
    assert(x < c);
    assert(y >= 0);
    assert(y < r);

    Field &f = fld[(y * c) + x];
    if (f != None)
        return false;

    return true;
}

bool Board::setField(int x, int y, Field color)
{
    if (!validMove(x, y, color))
        return false;
    fld[(y * c) + x] = color;
    boardChanged(x, y, 1, 1);
}

Board::Field Board::field(int x, int y) const
{
    assert(x >= 0);
    assert(x < c);
    assert(y >= 0);
    assert(y < r);
    return fld[(y * c) + x];
}

void Board::boardChanged(int left, int top, int width, int height)
{

}
